/**
 *  \file monAirportRhapsodyIDS.h (interface file)
 *
 *  \brief Problem name: Airport rhapsody.
 *
 *  \brief Concept: António Rui Borges
 *
 *  Synchronization based on monitors.
 *  Both threads and the monitor are implemented using the pthread library which enables the creation of a
 *  monitor of the Lampson / Redell type.
 *
 *  In order the students be able to develop and test separately the operations carried out by the porter,
 *  the passengers and the bus driver, the internal data structure is also made visible.
 *
 *  Definition of monitor internal data structure.
 *
 *  \author António Rui Borges - December 2013
 */

#ifndef MONAIRPORTRHAPSODYIDS_H_
#define MONAIRPORTRHAPSODYIDS_H_

#include <stdbool.h>
#include <pthread.h>

#include "probConst.h"
#include "probDataStruct.h"

/** \brief full state of the problem */
extern FULL_STAT fSt;

/** \brief porter waiting for work synchronization point */
extern pthread_cond_t waitingFlight;

/** \brief number of passengers who have executed the operation whatShouldIDo in each plane landing */
extern unsigned int nPassP;

/** \brief passengers synchronization point (one per passenger) */
extern pthread_cond_t pass[N];

/** \brief array of the number of calls made by the porter / bus driver to each passenger */
extern unsigned int nCalls[N];

/** \brief bus driver waiting for starting a new journey synchronization point */
extern pthread_cond_t waitingDrive;

/** \brief bus driver waiting for passengers to board / unboard synchronization point */
extern pthread_cond_t waitingPass;

/** \brief number of passengers who have executed either the operation enterTheBus or
 *  leaveTheBus in each bus transfer
 */
extern unsigned int nPassD;

/** \brief locking flag which warrants mutual exclusion inside the monitor */
extern pthread_mutex_t accessCR;

/** \brief flag which warrants internal data is initialized exactly once */
extern pthread_once_t init;

/**
 *  \brief Internal monitor operation.
 *
 *  Initialization of the internal data structure that contains the shared information and of the logging file.
 */

extern void initialization (void);

#endif /* MONAIRPORTRHAPSODYIDS_H_ */
